import { get, post, put } from '../utils/request.ts'

interface ReqAuthLoginParams {
  code: string;
  mobile: string;

  [key: string]: unknown;
}

export const reqAuthLogin = (params: ReqAuthLoginParams): Promise<{
  accessToken: string,
  refreshToken: string,
}> => post('/app-api/member/auth/login', params)

export const reqAuthLogout = () => post('/app-api/member/auth/logout')

export const sendSmsCode = (mobile: string, scene: SmsSceneEnum) => post('/app-api/member/auth/send-sms-code', { mobile, 'scene': scene || 1 })

/**
 * 重置密码
 * @param {object} params 用户 APP - 重置密码 Request VO
 * @param {string} params.password 新密码
 * @param {string} params.code 手机验证码
 * @param {string} params.mobile 手机号
 * @returns
 */
export const reqResetPassword = (params: any) => put('/app-api/member/user/reset-password', params)

export const reqQrUrl = (redirectUri: string) => get('/app-api/member/auth/social-auth-redirect?type=32&redirectUri=' + redirectUri)

export const socialLogin = (code: string, state: string) => post('/app-api/member/auth/social-login', { type: 32, code, state })

export enum SmsSceneEnum {
  LOGIN = 1,
  UPDATE_MOBILE = 2,
  UPDATE_PASSWORD = 3,
  RESET_PASSWORD = 4,
  BIND_MOBILE = 5,
}
